// @ts-ignore
/* eslint-disable */
import { request } from 'umi';
import { TableListItem } from './data';

export async function list(params: any) {
  return request('/api/bsDict/page', {
    method: 'POST',
    data: params,
  });
}

export async function codeList(params: any) {
  return request('/api/bsDictItem/page', {
    method: 'POST',
    data: params,
  });
}

export async function addDictItem(params: any) {
  return request('/api/bsDictItem/save', {
    method: 'POST',
    data: params,
  });
}

export async function upateDictItem(params: any) {
  return request('/api/bsDictItem/updateById', {
    method: 'PUT',
    data: params,
  });
}

export async function removeDictItem(params: any) {
  return request('/api/bsDictItem/' + params, {
    method: 'DELETE',
  });
}

/** 新建规则 PUT /api/Dict */
export async function updateDict(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/bsDict/updateById', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/Dict */
export async function addDict(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/bsDict/save', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/Dict */
export async function removeDict(data: { key: number[] }, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/bsDict/' + data.key, {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
